package com.eos.control.action.customer;

import com.eos.business.service.SysProductBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.common.tool.ObjectUtils;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.ProductModel;
import com.eos.orm.mybatis.model.SysUser;

public class SaveCategoryAction extends AbstractBaseAction {
	private static final long serialVersionUID = 169769270030882375L;
	private String modelName;
	private Integer brandId;
	private Integer sysProductId;
	private String modelDesc;
	
	public void setModelName(String modelName) {
		this.modelName = modelName;
	}

	public void setBrandId(Integer brandId) {
		this.brandId = brandId;
	}

	public void setSysProductId(Integer sysProductId) {
		this.sysProductId = sysProductId;
	}

	public void setModelDesc(String modelDesc) {
		this.modelDesc = modelDesc;
	}

	@Override
	public String execute() {
		 try {
			SysProductBusinessService spbs = new SysProductBusinessService();
			ProductModel pm = new ProductModel();
			pm.setBrandId(brandId);
			pm.setModelName(modelName);
			pm.setStatus(ConstantTool.STATUS_OK);
			pm.setDealFlag(ConstantTool.DEAL_FALG_OK);
			String strTime = ObjectUtils.formatDate(null, "yyyy-MM-dd HH:mm:ss");
			SysUser user = (SysUser) getSession().getAttribute("SysUser");
			String userId = user.getId()+"";
			pm.setInsertTime(strTime);
			pm.setInsertUserId(userId);
			pm.setModifyTime(strTime);
			pm.setUpdateUserId(userId);
			pm.setProductId(sysProductId);
			pm.setModelDesc(modelDesc);
			String exeStatus = spbs.saveProductModel(pm);
			if("SUCCESS".equals(exeStatus)){
				statusCode = "200";
				message = "保存型号信息成功!";
			}else{
				statusCode = "300";
				message = "系统繁忙, 保存型号信息失败!";
			}
		} catch (Exception e) {
			e.printStackTrace();
			statusCode = "300";
			message = "系统异常, 保存型号信息失败!";
		}
		return SUCCESS;
	}

}
